﻿<UserControl x:Class="ForumsBrowser.ThreadHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fb="clr-namespace:ForumsBrowser"
    HorizontalAlignment="Stretch"
    x:Name="threadHeader" FontFamily="Lucida Sans" Margin="0,0,0,10">
    <UserControl.Resources>
        <fb:ThreadColorConverter x:Key="colorConverter"/>
        <fb:ThreadToAnswerTextFormatter x:Key="answererFormatter"/>
    </UserControl.Resources>
    <Border BorderThickness="2" CornerRadius="5,5,5,5">
        <Border.BorderBrush>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="White" Offset="0"/>
                    <GradientStop Color="Black" Offset=".7"/>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Border.BorderBrush>
        <Border.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="{ Binding ElementName=threadHeader, Path=Thread, Converter={StaticResource colorConverter} }" Offset="0"/>
                    <GradientStop Color="Black" Offset=".3"/>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Border.Background> 
        <Grid VerticalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="*"/>
                <RowDefinition Height="20"/>
            </Grid.RowDefinitions>
            <TextBlock x:Name="titleBlock" Text="{Binding ElementName=threadHeader, 
                       Path=Thread.Title, FallbackValue=This is the title}" 
                       HorizontalAlignment="Stretch" Margin="20,0,20,1" 
                       VerticalAlignment="Center" FontSize="20"
                       FontWeight="Bold" Grid.Row="0" Foreground="White" 
                       MaxHeight="25" TextTrimming="CharacterEllipsis">
            </TextBlock>

            <TextBlock Grid.Row="1" Text="{Binding ElementName=threadHeader, Path=Thread.ForumName, 
                FallbackValue=Forum Name}" FontStyle="Italic" HorizontalAlignment="Stretch"  Margin="20,0,0,0"
                FontSize="14" Foreground="White">
            </TextBlock>
            <TextBlock Grid.Row="1" FontSize="14" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0">  
                <TextBlock.Text>
                        <MultiBinding StringFormat="{}Replies: {0}">
                            <Binding ElementName="threadHeader" Path="Thread.Replies" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            <TextBlock Grid.Row="2" FontSize="10" VerticalAlignment="Center" 
                       Margin="20,0,20,0" Text="{Binding ElementName=threadHeader, 
                        Path=Thread, Converter={StaticResource answererFormatter}, 
                        FallbackValue=Tada! }" 
                       Foreground="White"/>
        </Grid>
    </Border>
</UserControl>
